<template>
	<view class="content pbgc" v-if="JSON.stringify(data)!=='{}'">
		<view class="list">
			<template v-if="data.personal.status == -2">
				<view class="li"  @click="open('/pages/certification/individual/individual',1)">
					<image src="/static/member/c/c_01.png" mode=""></image>
					<view class="title">个人认证</view>
				</view>
			</template>
			<template v-else-if="data.personal.status == 0">
				<view class="li a"  >
					<image src="/static/member/c/c_01_a.png" mode=""></image>
					<view class="title">个人认证</view>
				</view>
			</template>
			<template v-else-if="data.personal.status == 1">
				<view class="li b" >
					<image src="/static/member/c/c_01_b.png" mode=""></image>
					<view class="title">个人认证</view>
				</view>
			</template>
			<template v-else-if="data.personal.status == -1">
				<view class="li c" @click="open('/pages/certification/individual/individual',1)">
					<image src="/static/member/c/c_03.png" mode=""></image>
					<view class="title">个人认证</view>
				</view>
			</template>
			
			<template v-if="data.shareholder.status == -2 && is_attest == 1">
				<view class="li" @click="open('/pages/certification/shareholder/shareholder',2)">
					<image src="/static/member/c/c_03.png" mode=""></image>
					<view class="title">股东认证</view>
				</view>
			</template>
			<template v-else-if="data.shareholder.status == 0">
				<view class="li a" >
					<image src="/static/member/c/c_03_a.png" mode=""></image>
					<view class="title">股东认证</view>
				</view>
			</template>
			<template v-else-if="data.shareholder.status == 1">
				<view class="li b" >
					<image src="/static/member/c/c_03_b.png" mode=""></image>
					<view class="title">股东认证</view>
				</view>
			</template>
			<template v-else-if="data.shareholder.status == -1">
				<view class="li c"   @click="open('/pages/certification/shareholder/shareholder',2)">
					<image src="/static/member/c/c_03.png" mode=""></image>
					<view class="title">股东认证</view>
				</view>
			</template>
			
			<template v-if="data.company.status == -2 && is_attest > 0 && (agent_level_id < 4 || is_store > 0)">
				<view class="li " @click="open('/pages/certification/business/business',3)">
					<image src="/static/member/c/c_02.png" mode=""></image>
					<view class="title">企业认证</view>
				</view>
			</template>
			<template v-else-if="data.company.status == 0">
				<view class="li a">
					<image src="/static/member/c/c_02_a.png" mode=""></image>
					<view class="title">企业认证</view>
				</view>
			</template>
			<template v-else-if="data.company.status == 1">
				<view class="li b">
					<image src="/static/member/c/c_02_b.png" mode=""></image>
					<view class="title">企业认证</view>
				</view>
			</template>
			<template v-else-if="data.company.status == -1">
				<view class="li c" @click="open('/pages/certification/business/business',3)">
					<image src="/static/member/c/c_02.png" mode="a"></image>
					<view class="title">企业认证</view>
				</view>
			</template>
			
		</view>
	</view>
</template>

<script>
	import {
        mapState,
        mapMutations
    } from 'vuex'
	export default {
		computed: {
            ...mapState(['token'])
        },
		data() {
			return {
				data: {},
				is_attest:0,
				agent_level_id: 0,
				is_store: 0
			}
		},
		onShow() {
			if(this.token){
				this.getType()
				this.getMemberInfo()
			}
		},
		methods: {
			...mapMutations(['getNetworkType','vuexRequest']),
			open(url,type) { 
				if(this.token){
					// 股东
					if(type == 1 && this.is_attest == 0){
						uni.navigateTo({
							url: url + '?type=' + this.data.personal.status + '&remark='+ this.data.personal.remark
						});
						return !1
					}
					// 股东
					if(type == 2 && this.is_attest == 1){
						uni.navigateTo({
							url: url + '?type=' + this.data.shareholder.status + '&remark='+ this.data.shareholder.remark
						});
						return !1
					}
					// 企业
					if(type == 3 && this.is_attest > 0 && (this.agent_level_id < 4 || this.is_store > 0)){
						uni.navigateTo({
							url: url + '?type=' + this.data.company.status + '&remark='+ this.data.company.remark
						});
						return !1
					}
					uni.showToast({
						icon: 'none',
						title: "您暂时不能进行此认证",
						position:'bottom'
					})
				}else{
					uni.navigateTo({
						url: '/pages/login/login/login'
					});
				}
			},
			getType() {
				this.vuexRequest({
					url: '/api/addons/execute?route=member-id/get-id&addon=o-s-mall-dist&access-token=' + this.token,
					method: 'GET',
					data: {},
					success: (res)  => {
						console.log(res.data.data)
						this.data = res.data.data
					},
					fail: (err)  => {
					},
				})
			},
			getMemberInfo() {
				this.vuexRequest({
					url: '/api/addons/execute?route=member/info&addon=o-s-mall-dist&access-token=' + this.token,
					method: 'GET',
					data: {},
					success: (res)  => {
						this.is_attest = res.data.data.agent_info.is_attest
						this.agent_level_id = res.data.data.agent_info.agent_level_id
						this.is_store = res.data.data.agent_info.is_store
						console.log(this.is_attest)
						console.log(this.agent_level_id)
						console.log(this.is_store)
					},
					fail: (err)  => {
					},
				})
			}
		},
		onReady() {
			/* this.data={company:{status:-2},personal:{status:-2},shareholder:{status:-2}}
			this.is_attest = 0
			this.agent_level_id = 5
			this.is_store = -1 */
		}
	}
</script>

<style>
	.list .li{
		background: #FFFFFF;
		margin: 30upx 30upx 30upx 30upx;
		border-radius: 20upx;
		min-height: 240upx;
		position: relative;
		text-align: center;
		padding: 80upx 0 60upx 0;
		overflow: hidden;
		color: #d8d8d8;
	}
	.list .li image{
		width: 160upx;
		height: 160upx;
		margin: 0 auto;
	}
	.list .li:after{
		position: absolute;
		display: block;
		color: #FFFFFF;
		width: 300upx;
		height: 60upx;
		content: '';
		padding: 40upx 0 0 0;
		top: -10upx;
		right: -115upx;
		transform:rotate(45deg);
	}
	.list .li.a{
		color:#f0a73e ;
	}
	.list .li.a:after{
		content: '审核中';
		background: #f0a73e;
	}
	.list .li.b{
		color:#e83e41 ;
	}
	.list .li.b:after{
		content: '已认证';
		background: #e83e41;
	}
	.list .li.c:after{
		content: '被驳回';
		background: #e83e41;
	}
</style>
